package com.ziven.learn.model;

import android.content.Context;

import androidx.annotation.Nullable;

import com.ziven.easygo.design.mvp.OneData;
import com.ziven.easygo.overall.OverallModel;
import com.ziven.easygo.util.DataProvider;
import com.ziven.easygo.util.LogHelper;
import com.ziven.learn.LearnUtils;
import com.ziven.learn.bean.MixedRowBean;

import java.util.Map;

/**
 * @author Ziven
 */
public class MixedRowModel extends OverallModel {

    public final static String GRID_VIEW = "GRID_VIEW";

    @Override
    protected void obtainOneData(@Nullable Context c, @Nullable Map<Object, Object> params) {
        LogHelper.of("MixedRowModel").join(getBoolean(GRID_VIEW, params)).print();
        if(getBoolean(GRID_VIEW, params)) {
            obtainedOneData(OneData.of(DataProvider
                    .ofData(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .getList()));
        } else {
            obtainedOneData(OneData.of(DataProvider
                    .ofData(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .add(factory(MixedRowBean.TYPE_SINGLE))
                    .add(factory(MixedRowBean.TYPE_MULTI))
                    .getList()));
        }
    }

    private MixedRowBean factory(int type) {
        return new MixedRowBean()
                .setViewType2(type)
                .setViewColor(LearnUtils.color())
                .setViewColor2(LearnUtils.color());
    }
}
